package com.example.flow.flow.model.vo;


import com.example.flow.dao.model.FlowProcess;
import com.example.flow.flow.model.TaskModel;
import com.example.flow.flow.model.TaskParse;
import lombok.Data;

import java.util.LinkedList;
import java.util.List;

@Data
public class FlowProcessDetailVo {
    private static final long serialVersionUID = 1670984117619134464L;

    private String processId;
    private String processName;
    private String description;
    private String processType;
    private Integer version;
    private String creator;
    private Integer maxValidDay;
    private List<TaskParse> tasks;
    private Long cts;

    public FlowProcessDetailVo(FlowProcess flowProcess) {
        this.processId = flowProcess.getProcessId();
        this.processName = flowProcess.getProcessName();
        this.description = flowProcess.getDescription();
        this.processType = flowProcess.getProcessType();
        this.version = flowProcess.getVersion();
        this.maxValidDay = flowProcess.getMaxValidDay();
        this.creator = flowProcess.getCreator();
        this.cts = flowProcess.getCts();
        List<TaskParse> taskParses = new LinkedList<>();
        TaskParse taskParse;
        if (flowProcess.getFlowNodes() != null) {
            for (TaskModel task : flowProcess.getFlowNodes().getTasks()) {
                taskParse = new TaskParse();
                taskParse.setName(task.getName());
                taskParse.setApprover(task.getApprover());
                taskParse.setApproverType(task.getApproverType());
                taskParse.setCurrentOperatorGuid(task.getCurrentOperatorGuid());
                taskParse.setCurrentOperatorName(task.getCurrentOperatorName());
                taskParse.setAllowStop(task.getAllowStop());
                taskParses.add(taskParse);
            }
        }
        this.tasks = taskParses;
    }

    public FlowProcessDetailVo() {
    }
}
